package cn.zerlynn.sql.dialect.model;

/**
 * PageParam
 *
 * @author: zerlynn
 * @createTime: 2024/10/24 0:46
 */
public class PageParam {
    private final int pageNumber;
    private final int pageSize;

    public PageParam(int pageNumber, int pageSize) {
        if (pageNumber < 1 || pageSize < 1) {
            throw new IllegalArgumentException("Page number and page size must be positive.");
        }
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public int getPageSize() {
        return pageSize;
    }

    /**
     * 计算分页查询的偏移量。
     */
    public int getOffset() {
        return (pageNumber - 1) * pageSize;
    }
}
